package role

import (
	"context"

	"go-zero-mall/app/admin/cmd/api/internal/svc"
	"go-zero-mall/app/admin/cmd/api/internal/types"
	"go-zero-mall/app/admin/cmd/rpc/pd"

	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type RoleListAllLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRoleListAllLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleListAllLogic {
	return &RoleListAllLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RoleListAllLogic) RoleListAll(req *types.RoleListAllReq) (resp *types.RoleListAllResp, err error) {
	var in pd.Request
	data, err := l.svcCtx.AdminRpc.RoleListAll(l.ctx, &in)
	resp = new(types.RoleListAllResp)
	copier.Copy(&resp, data)
	return resp, err
}
